x = open("第二周_第2节tmp.py", "r", encoding="utf-8")
f = open("第二周_第2节.py", "a", encoding="utf-8")
f.write(x.read())
x.close()
f.close()
#!/usr/bin/env python
# -*-coding:utf-8 -*-

# Author:Lim
a = 'ab'
b = 'bc'
a += b
print(a)
print(a.find('b'))
print(a.index('b'))
print(a.find('d'))
print(a.startswith('ab'))
print(a.endswith('c'))
print(a[1:3])
print(a.replace('c','e'))
a = 'abbc d'
print(a.split(' '))
tmp = a.split(' ')
print(' '.join(tmp))
a = ' nihao '
print(a)
print(a.strip())
a = ' nihao '
print(a.lstrip())
print(a.rstrip())

#format
#按传入参数的默认顺序
print('{}-{}-{}'.format(2020,10,25))
#按指定参数索引
print('{0}{1}{0}'.format('帅','不'))
#按关键词参数
print('{city}-{name}'.format(name = 'Lim',city = 'shenzhen'))
#按变量
city = 'beijing'
name = 'tony'
print(f'{city}-{name}')
#处理浮点数
print('{:.3f}'.format(3.1415926))